package org.example.aop.controller;

import org.example.aop.annotation.DistributedLock;
import org.example.aop.annotation.PermissionAnnotation;
import org.example.aop.dto.request.UserRequest;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 */
@RestController
@RequestMapping("/aop")
public class TestController {
    @GetMapping("getTest")
    public String getTest() {
        System.out.println("开始执行请求：getTest.......");
        return "getTest.........";
    }

    @PostMapping("postTest")
    @PermissionAnnotation()
    public String postTest(@RequestBody UserRequest request) {
        System.out.println("开始执行请求：postTest.......");
        return "postTest.......";
    }

    @PostMapping("postTest1")
    @DistributedLock(lockKey = "test1_#{request.id}_#{request.name}")
    public String postTest1(@RequestBody UserRequest request) {
        System.out.println("开始执行请求：postTest1.......");
        return "postTest1.......";
    }

    @PostMapping("postTest2/{id}")
    @DistributedLock(lockKey = "test2_#{id}")
    public String postTest2(@PathVariable("id") Long id) {
        System.out.println("开始执行请求：postTest2.......");
        return "postTest2.......";
    }
}
